cmake_minimum_required(VERSION 3.10)  # 建议使用最新稳定版

# ----------------------
# 基础配置
# ----------------------
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# 定义路径变量（明确项目结构）
set(PROJECT_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
set(PROJECT_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")

# # ----------------------
# # 依赖查找
# # ----------------------
# 查找 PCL 库
find_package(PCL 1.8 REQUIRED COMPONENTS common visualization)
if(PCL_FOUND)
    message(STATUS "PCL found: ${PCL_VERSION}")
    include_directories(${PCL_INCLUDE_DIRS})
    link_directories(${PCL_LIBRARY_DIRS})
    add_definitions(${PCL_DEFINITIONS})
else()
    message(FATAL_ERROR "PCL not found. Please install PCL library.")
endif()

# ----------------------
# 静态库定义
# ----------------------
set(DISPLAY_SDK_LIBRARY ${PROJECT_NAME}_display_static)
add_library(${DISPLAY_SDK_LIBRARY} STATIC
    ${PROJECT_SRC_DIR}/point_display.cpp
)

# ----------------------
# 头文件管理
# ----------------------
target_include_directories(${DISPLAY_SDK_LIBRARY}
    PUBLIC  # 外部项目包含此路径即可使用库接口
        ${PROJECT_INCLUDE_DIR}
        ${PCL_INCLUDE_DIRS}
)

# 指定公共头文件（用于安装和IDE索引）
set_target_properties(${DISPLAY_SDK_LIBRARY} 
    PROPERTIES
    PUBLIC_HEADER "include/point_display.h"
)


# ----------------------
# 编译选项
# ----------------------
target_compile_options(${DISPLAY_SDK_LIBRARY} PRIVATE
    $<$<CXX_COMPILER_ID:GNU>:-Wall -Wextra -pedantic -Wno-c++11-long-long>  # GCC警告
    $<$<CXX_COMPILER_ID:Clang>:-Wall -Wextra -pedantic -Wno-unknown-pragmas>  # Clang警告
    $<$<CXX_COMPILER_ID:AppleClang>:-Wall -Wextra -pedantic -Wno-unknown-pragmas>  # Apple Clang警告
)

# ----------------------
# 依赖链接（静态库内部依赖）
# ----------------------
set(PT_LIBS ${PROJECT_NAME}_pt_static)
target_link_libraries(${DISPLAY_SDK_LIBRARY} 
    # PRIVATE
    ${PCL_LIBRARIES}
    ${PT_LIBS}
)

# ----------------------
# 安装配置（可选，用于打包）
# ----------------------